﻿Public Class frmResultControl
    ''' <summary>
    ''' 用户选中的项目
    ''' </summary>
    ''' <remarks></remarks>
    Public proj As New CAermod.ProjSet



    Public FileType As FileType
    ''' <summary>
    ''' 用于保存较老的等值线层的Key，以便于叠加或删除等值线层
    ''' </summary>
    ''' <remarks></remarks>
    Private m_OldContourdKey As String
    ''' <summary>
    ''' 用于保存较老的
    ''' </summary>
    ''' <value></value>
    ''' <returns></returns>
    ''' <remarks></remarks>
    Property OldContourdKey() As String
        Get
            Return Me.m_OldContourdKey
        End Get
        Set(ByVal value As String)
            Me.m_OldContourdKey = value
        End Set
    End Property
    ''' <summary>
    ''' 根据用户的选择获取文件
    ''' </summary>
    ''' <remarks></remarks>
    Private Sub GetDataAndShow()
        Select Case Me.FileType

            Case AermodSystem.FileType.Rectable '各点高值
                GetDataFromPlotFileAndShow()
            Case AermodSystem.FileType.Maxtable '所有点最大值
                GetDataFromMaxFileAndShow()
            Case AermodSystem.FileType.Post '逐步值文件
                GetDataFromPostFileAndShow()
            Case AermodSystem.FileType.Over  '超标率分析
                GetOverDataFromPostFileAndShow()
        End Select

    End Sub
    Private Sub frmResultControl_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
        cmbNumber.SelectedIndex = 5
        cmbAddBackCon.SelectedIndex = 0
    End Sub
#Region "各点高值"
    Private Sub GetDataFromPlotFileAndShow()
        If Me.cmbGroups.SelectedIndex >= 0 And Me.cmbAverageTime.SelectedIndex >= 0 And Me.cmbRectable.SelectedIndex >= 0 And Me.cmbGrid.SelectedIndex >= 0 Then
            Dim ResultNameAndData As New CAermod.ResultNameAndData
            Dim FileName As String = ""
            GetDataFromPlotFile(ResultNameAndData, FileName)
            ShowRectableToMapAndGrid(ResultNameAndData, FileName)
            ShowRecatableToCareTable(ResultNameAndData)
        End If
    End Sub
    ''' <summary>
    ''' 获取文件中的数据
    ''' </summary>
    ''' <param name="ResultNameAndData"></param>
    ''' <param name="PlotFileName"></param>
    ''' <remarks></remarks>
    Public Sub GetDataFromPlotFile(ByRef ResultNameAndData As CAermod.ResultNameAndData, ByRef PlotFileName As String)
        Dim MyMainFrm As frmMain = My.Application.ApplicationContext.MainForm
        Dim PLT As String = ""

        Select Case Me.cmbRectable.SelectedIndex
            Case 0 '第1大
                PLT = "_FIRST.PLT"
            Case 1
                PLT = "_SECOND.PLT"
            Case 2
                PLT = "_THIRD.PLT"
            Case 3
                PLT = "_FOURTH.PLT"
            Case 4
                PLT = "_FIFTH.PLT"
            Case 5
                PLT = "_SIXTH.PLT"
            Case 6
                PLT = "_SEVENTH.PLT"
            Case 7
                PLT = "_EIGHTH.PLT"
            Case 8
                PLT = "_NINTH.PLT"
            Case 9
                PLT = "_TENTH.PLT"
        End Select
        Dim Path As String = System.IO.Path.GetDirectoryName(AermodProject0.SaveName) & "\" & CAermod.GetFileName(AermodProject0.SaveName)
        If Me.cmbAverageTime.Text = "期间平均" Then
            PlotFileName = Path & "\Aermod\" _
                & Me.proj.ID & "\" & Me.proj.TempAermod.Source.Groups.ArrayGroup(Me.cmbGroups.SelectedIndex).GroupID & "_PLOT_PERIOD.PLT"
            ResultNameAndData.GetDataFromPlotFile(Me.proj.TempAermod.Receptor, Me.proj.TempAermod.Control.AllPolluts.AllSelectPollut(0).Dispersion.DEPOS, PlotFileName)
        Else
            PlotFileName = Path & "\Aermod\" _
                & Me.proj.ID & "\" & Me.proj.TempAermod.Source.Groups.ArrayGroup(Me.cmbGroups.SelectedIndex).GroupID & "_PLOT_" _
                & Me.proj.TempAermod.Control.AerageingTime.GetSelectedAerageingTime(Me.cmbAverageTime.SelectedIndex).ToString & PLT
            ResultNameAndData.GetDataFromPlotFile(Me.proj.TempAermod.Receptor, Me.proj.TempAermod.Control.AllPolluts.AllSelectPollut(0).Dispersion.DEPOS, PlotFileName)

        End If
    End Sub
    ''' <summary>
    ''' 在图和对应的表中显示网格数据
    ''' </summary>
    ''' <param name="ResultNameAndData"></param>
    ''' <param name="PlotFileName"></param>
    ''' <remarks></remarks>
    Private Sub ShowRectableToMapAndGrid(ByRef ResultNameAndData As CAermod.ResultNameAndData, ByRef PlotFileName As String)

        Dim MyMainFrm As frmMain = My.Application.ApplicationContext.MainForm
        Dim Grid(Me.proj.TempAermod.Receptor.SubGridCart(Me.cmbGrid.SelectedIndex).Ynum - 1, Me.proj.TempAermod.Receptor.SubGridCart(Me.cmbGrid.SelectedIndex).Xnum - 1) As Double
        Dim SaveContourFileName As String = CAermod.GetFileName(PlotFileName) & "_" & Me.cmbGrid.SelectedIndex

        If Me.proj.TempAermod.Receptor.SubGridCart(Me.cmbGrid.SelectedIndex).Selected = True Then
            Select Case Me.cmbCon.Text
                Case "浓度"
                    For i As Integer = 0 To Me.proj.TempAermod.Receptor.SubGridCart(Me.cmbGrid.SelectedIndex).Ynum - 1
                        For j As Integer = 0 To Me.proj.TempAermod.Receptor.SubGridCart(Me.cmbGrid.SelectedIndex).Xnum - 1
                            Grid(i, j) = ResultNameAndData.m_SubGridConDEPOS(Me.cmbGrid.SelectedIndex)(i, j).con / 1000
                        Next
                    Next
                    '获取背景浓度的数组
                    Dim disCarePoint3d(-1) As CAermod.Point3D
                    Dim disCon(-1) As Double
                    For j As Integer = 0 To Me.proj.TempAermod.Receptor.DiscCarts.Length - 1
                        If Me.proj.TempAermod.BackCon.PollutBackCon.Item(0).GetBackCon(Me.cmbAverageTime.Text).ListCareBackCon(j).Con >= 0 Then
                            ReDim Preserve disCarePoint3d(disCarePoint3d.Length)
                            ReDim Preserve disCon(disCon.Length)
                            disCarePoint3d(disCarePoint3d.Length - 1) = New CAermod.Point3D
                            disCarePoint3d(disCarePoint3d.Length - 1).x = Me.proj.TempAermod.Receptor.DiscCarts(j).Xcoord
                            disCarePoint3d(disCarePoint3d.Length - 1).y = Me.proj.TempAermod.Receptor.DiscCarts(j).Ycoord
                            disCarePoint3d(disCarePoint3d.Length - 1).z = Me.proj.TempAermod.Receptor.DiscCarts(j).Zelev
                            disCon(disCarePoint3d.Length - 1) = Me.proj.TempAermod.BackCon.PollutBackCon.Item(0).GetBackCon(Me.cmbAverageTime.Text).ListCareBackCon(j).Con
                        End If
                    Next

                    If Me.cmbAddBackCon.Text = "叠加" Then '如果叠加背景值，采用反距离平方法求得每个网格点的背景值
                        SaveContourFileName += "_AddBack"
                        If disCarePoint3d.Length > 0 Then
                            Dim BackGrid(Me.proj.TempAermod.Receptor.SubGridCart(Me.cmbGrid.SelectedIndex).Ynum - 1, Me.proj.TempAermod.Receptor.SubGridCart(Me.cmbGrid.SelectedIndex).Xnum - 1) As Double
                            For i As Integer = 0 To Me.proj.TempAermod.Receptor.SubGridCart(Me.cmbGrid.SelectedIndex).Ynum - 1
                                For j As Integer = 0 To Me.proj.TempAermod.Receptor.SubGridCart(Me.cmbGrid.SelectedIndex).Xnum - 1
                                    Dim Grid3d As New CAermod.Point3D
                                    Grid3d.x = ResultNameAndData.m_SubGridConDEPOS(Me.cmbGrid.SelectedIndex)(i, j).x
                                    Grid3d.y = ResultNameAndData.m_SubGridConDEPOS(Me.cmbGrid.SelectedIndex)(i, j).y
                                    Grid3d.z = ResultNameAndData.m_SubGridConDEPOS(Me.cmbGrid.SelectedIndex)(i, j).z

                                    BackGrid(i, j) = CAermod.PublicFunction.GetLocationCon(Grid3d, disCarePoint3d, disCon)
                                    Grid(i, j) += BackGrid(i, j)
                                Next
                            Next
                        End If
                    End If
                Case "总沉积"
                    For i As Integer = 0 To Me.proj.TempAermod.Receptor.SubGridCart(Me.cmbGrid.SelectedIndex).Ynum - 1
                        For j As Integer = 0 To Me.proj.TempAermod.Receptor.SubGridCart(Me.cmbGrid.SelectedIndex).Xnum - 1
                            Grid(i, j) = ResultNameAndData.m_SubGridConDEPOS(Me.cmbGrid.SelectedIndex)(i, j).DEPOS
                        Next
                    Next
                    SaveContourFileName += "_DEPOS"
                Case "干沉积"
                    For i As Integer = 0 To Me.proj.TempAermod.Receptor.SubGridCart(Me.cmbGrid.SelectedIndex).Ynum - 1
                        For j As Integer = 0 To Me.proj.TempAermod.Receptor.SubGridCart(Me.cmbGrid.SelectedIndex).Xnum - 1
                            Grid(i, j) = ResultNameAndData.m_SubGridConDEPOS(Me.cmbGrid.SelectedIndex)(i, j).DDEP
                        Next
                    Next
                    SaveContourFileName += "_DDEP"
                Case "湿沉积"
                    For i As Integer = 0 To Me.proj.TempAermod.Receptor.SubGridCart(Me.cmbGrid.SelectedIndex).Ynum - 1
                        For j As Integer = 0 To Me.proj.TempAermod.Receptor.SubGridCart(Me.cmbGrid.SelectedIndex).Xnum - 1
                            Grid(i, j) = ResultNameAndData.m_SubGridConDEPOS(Me.cmbGrid.SelectedIndex)(i, j).WDEP
                        Next
                    Next
                    SaveContourFileName += "_WDEP"
            End Select
        End If

        '用于保存等值线的文件的名称
        ChangeContours(Grid, Me.proj.TempAermod.Receptor.SubGridCart(Me.cmbGrid.SelectedIndex).Xinit, Me.proj.TempAermod.Receptor.SubGridCart(Me.cmbGrid.SelectedIndex).Xdelta, Me.proj.TempAermod.Receptor.SubGridCart(Me.cmbGrid.SelectedIndex).Xnum _
                       , Me.proj.TempAermod.Receptor.SubGridCart(Me.cmbGrid.SelectedIndex).Yinit, Me.proj.TempAermod.Receptor.SubGridCart(Me.cmbGrid.SelectedIndex).Ydelta, Me.proj.TempAermod.Receptor.SubGridCart(Me.cmbGrid.SelectedIndex).Ynum _
                      , AermodProject0.GetOffsetX, AermodProject0.GetOffsetY, SaveContourFileName, True)
    End Sub
    ''' <summary>
    ''' 根据网格数据显示等值线图和网格数据
    ''' </summary>
    ''' <param name="Grid">网格数据，二维数组</param>
    ''' <param name="Xmin">X方向最小值</param>
    ''' <param name="Xdelta">X方向步长</param>
    ''' <param name="Xnum">X方向网格点数</param>
    ''' <param name="Ymin">Y方向最小值</param>
    ''' <param name="Ydelta">Y方向步长</param>
    ''' <param name="Ynum">Y方向最小值</param>
    ''' <param name="ContourKey">等值线图层的关键字</param>
    ''' <param name="OffsetX">X方向的偏移量</param>
    ''' <param name="OffsetY">Y方向的偏移量</param>
    ''' <param name="IsSave">是否是保存等值线图</param>
    ''' <remarks></remarks>
    Public Sub ChangeContours(ByVal Grid(,) As Double, ByVal Xmin As Double, ByVal Xdelta As Double, ByVal Xnum As Double _
                          , ByVal Ymin As Double, ByVal Ydelta As Double, ByVal Ynum As Double _
                          , ByVal OffsetX As Double, ByVal OffsetY As Double, ByVal ContourKey As String, ByVal IsSave As Boolean)
        Dim MyMainFrm As frmMain = My.Application.ApplicationContext.MainForm
        Dim dblA() As Double = GetContourValue(Grid, Ynum, Ymin, Ymin + (Ynum - 1) * Ydelta _
                    , Xnum, Xmin, Xmin + (Xnum - 1) * Xdelta)
        MyMainFrm.frmAnalyse.frmGis_Map.SetContour(Grid, Ynum, Ymin, Ymin + (Ynum - 1) * Ydelta _
                    , Xnum, Xmin, Xmin + (Xnum - 1) * Xdelta, OffsetX, OffsetY, ContourKey, IsSave, dblA)
        '设置网格数据
        MyMainFrm.frmAnalyse.frmGridResult.SetGrid(Grid, Ynum, Ymin, Ymin + (Ynum - 1) * Ydelta _
                    , Xnum, Xmin, Xmin + (Xnum - 1) * Xdelta, Me.cmbNumber.SelectedIndex)


        Try
            '三维相关

            Dim cons As New DrawContour.Contours()

            cons.SetGrid(Xmin, Xdelta, Xnum, Ymin, Ydelta, Ynum, Grid)


            '这个只是暂时的代码，回头需要改进的。
            cons.ResetContourData(dblA)


            'MyMainFrm.frmAnalyse.m_vtkRenderForm.ContourPaintForm1.ContourPaintSetting.ContourPannel.Contours = cons
            'DrawContour.publicVar.ActivePaintForm = MyMainFrm.frmAnalyse.m_vtkRenderForm.ContourPaintForm1
            'DrawContour.publicVar.ActivePaintForm.ContourPaintSetting.ContourPannel.Contours = cons

            'MyMainFrm.frmAnalyse.m_vtkRenderForm.ChangeContour(cons, OffsetX, OffsetY, ContourKey, IsSave)



            ''我彻底拜倒，代码反了
            ''fucon = dlgVtk.ContourPaintForm1.ContourPaintSetting.ContourPannel.Contours


            'dlgVtk.ContourPaintForm1.ContourPaintSetting.ContourPannel.Contours = fucon

            'Dim dval(3) As Double
            'dval(0) = 0.1
            'dval(1) = 0.2

            'dval(2) = 0.3
            'dval(3) = 0.4


            '下面这个代码的作用暂时被取消了。
            MyMainFrm.frmAnalyse.fucon.SetGrid(Xmin, Xdelta, Xnum, Ymin, Ydelta, Ynum, Grid)


            'MyMainFrm.frmAnalyse.m_vtkRenderForm.ChangeContour()
        Catch ex As Exception

        End Try




    End Sub

    Public Function GetContourValue(ByVal Grid(,) As Double, ByVal nRow As Double, ByVal Ymin As Double, ByVal Ymax As Double _
                          , ByVal nCol As Double, ByVal Xmin As Double, ByVal Xmax As Double) As Double()
        Dim Max As Double = -999999999
        Dim Min As Double = 999999999
        For i As Integer = 0 To nRow - 1
            For j As Integer = 0 To nCol - 1
                If Min > Grid(i, j) Then
                    Min = Grid(i, j)
                End If
                If Max < Grid(i, j) Then
                    Max = Grid(i, j)
                End If
            Next
        Next

        '设置等值线名称和值的数组
        Dim n As Integer = 20
        Dim Increase As Double = 0
        Dim dblA(-1) As Double

        If Max <> -999999999 And Max > 0 Then
            'Min = Max / 20
            Max = Max - Increase * n / 2
            Increase = (Max - Min) / n
            Dim j As Integer = 0
            For j = 0 To 100 '选取整数来分析
                If CInt(Increase * 10 ^ j) > 0 Then
                    Increase = CInt(Increase * 10 ^ j) / 10 ^ j
                    Exit For
                End If
            Next

            Min = Min + Increase * n / 8

            Min = FormatNumber(Min, j)
            For i As Integer = 0 To n - 1 - 10
                Dim dblValue As Double = Min + Increase * i
                ReDim Preserve dblA(dblA.Length)
                dblA(dblA.Length - 1) = dblValue
                If dblA.Length >= n Then
                    Exit For
                End If
            Next
        End If
        Return dblA
    End Function

    ''' <summary>
    ''' 在表中显示关心点的数据
    ''' </summary>
    ''' <param name="ResultNameAndData"></param>
    ''' <remarks></remarks>
    Private Sub ShowRecatableToCareTable(ByRef ResultNameAndData As CAermod.ResultNameAndData)
        Try
            Dim myFrmMain As frmMain = My.Application.ApplicationContext.MainForm
            myFrmMain.frmAnalyse.frmRectable.EFlex1.Rows.Count = 1
            '设置列数及行标题
            myFrmMain.frmAnalyse.frmRectable.EFlex1.Cols.Count = 15
            myFrmMain.frmAnalyse.frmRectable.EFlex1.AllowSorting = C1.Win.C1FlexGrid.AllowSortingEnum.None
            myFrmMain.frmAnalyse.frmRectable.EFlex1.AllowResizing = C1.Win.C1FlexGrid.AllowResizingEnum.Columns
            myFrmMain.frmAnalyse.frmRectable.EFlex1.AllowDragging = C1.Win.C1FlexGrid.AllowDraggingEnum.None
            myFrmMain.frmAnalyse.frmRectable.EFlex1.AllowMerging = C1.Win.C1FlexGrid.AllowMergingEnum.Free
            For i As Integer = 0 To 2
                myFrmMain.frmAnalyse.frmRectable.EFlex1.Cols(i).AllowMerging = True
            Next
            myFrmMain.frmAnalyse.frmRectable.EFlex1.SetData(0, 0, "序号")
            myFrmMain.frmAnalyse.frmRectable.EFlex1.SetData(0, 1, "污染物名称")
            myFrmMain.frmAnalyse.frmRectable.EFlex1.SetData(0, 2, "关心点")
            myFrmMain.frmAnalyse.frmRectable.EFlex1.SetData(0, 3, "坐标[x,y,z]")
            myFrmMain.frmAnalyse.frmRectable.EFlex1.SetData(0, 4, "平均时间")
            myFrmMain.frmAnalyse.frmRectable.EFlex1.SetData(0, 5, "浓度排序")
            myFrmMain.frmAnalyse.frmRectable.EFlex1.SetData(0, 6, "浓度值[mg/m^3]")
            myFrmMain.frmAnalyse.frmRectable.EFlex1.SetData(0, 7, "出现时刻")
            myFrmMain.frmAnalyse.frmRectable.EFlex1.SetData(0, 8, "背景值[mg/m^3]")
            myFrmMain.frmAnalyse.frmRectable.EFlex1.SetData(0, 9, "预测值[mg/m^3]")
            myFrmMain.frmAnalyse.frmRectable.EFlex1.SetData(0, 10, "标准值")
            myFrmMain.frmAnalyse.frmRectable.EFlex1.SetData(0, 11, "占标率[%]")
            If myFrmMain.frmAnalyse.NowProj.TempAermod.Control.AllPolluts.AllSelectPollut(0).Dispersion.DEPOS = True Then
                myFrmMain.frmAnalyse.frmRectable.EFlex1.SetData(0, 12, "总沉积[g/m^2]")
                myFrmMain.frmAnalyse.frmRectable.EFlex1.SetData(0, 13, "干沉积[g/m^2]")
                myFrmMain.frmAnalyse.frmRectable.EFlex1.SetData(0, 14, "湿沉积[g/m^2]")

            End If

            myFrmMain.frmAnalyse.frmRectable.EFlex1.AutoSizeCols()


            '获取背景浓度的数组
            Dim disCarePoint3d(-1) As CAermod.Point3D
            Dim disCon(-1) As Double
            For j As Integer = 0 To Me.proj.TempAermod.Receptor.DiscCarts.Length - 1
                If Me.proj.TempAermod.Receptor.DiscCarts(j).Selected = True Then
                    If Me.proj.TempAermod.BackCon.PollutBackCon.Item(0).GetBackCon(Me.cmbAverageTime.Text).ListCareBackCon(j).Con >= 0 Then
                        ReDim Preserve disCarePoint3d(disCarePoint3d.Length)
                        ReDim Preserve disCon(disCon.Length)
                        disCarePoint3d(disCarePoint3d.Length - 1) = New CAermod.Point3D
                        disCarePoint3d(disCarePoint3d.Length - 1).x = Me.proj.TempAermod.Receptor.DiscCarts(j).Xcoord
                        disCarePoint3d(disCarePoint3d.Length - 1).y = Me.proj.TempAermod.Receptor.DiscCarts(j).Ycoord
                        disCarePoint3d(disCarePoint3d.Length - 1).z = Me.proj.TempAermod.Receptor.DiscCarts(j).Zelev
                        disCon(disCarePoint3d.Length - 1) = Me.proj.TempAermod.BackCon.PollutBackCon.Item(0).GetBackCon(Me.cmbAverageTime.Text).ListCareBackCon(j).Con
                    End If
                End If
            Next
            Dim Backcon As Double
            '设置表格的行数=（关心点个数+1）*输出的最大浓度的个数
            myFrmMain.frmAnalyse.frmRectable.EFlex1.Rows.Count = 1
            For i As Integer = 0 To Me.proj.TempAermod.Receptor.DiscCarts.Length - 1
                If Me.proj.TempAermod.Receptor.DiscCarts(i).Selected = True Then
                    myFrmMain.frmAnalyse.frmRectable.EFlex1.Rows.Count += 1
                    myFrmMain.frmAnalyse.frmRectable.EFlex1.SetData(myFrmMain.frmAnalyse.frmRectable.EFlex1.Rows.Count - 1, 1, Me.proj.TempAermod.Control.AllPolluts.AllSelectPollut(0).Name)
                    myFrmMain.frmAnalyse.frmRectable.EFlex1.SetData(myFrmMain.frmAnalyse.frmRectable.EFlex1.Rows.Count - 1, 2, Me.proj.TempAermod.Receptor.DiscCarts(i).Name)
                    myFrmMain.frmAnalyse.frmRectable.EFlex1.SetData(myFrmMain.frmAnalyse.frmRectable.EFlex1.Rows.Count - 1, 3, Me.proj.TempAermod.Receptor.DiscCarts(i).Xcoord & "," & Me.proj.TempAermod.Receptor.DiscCarts(i).Ycoord & "," & Me.proj.TempAermod.Receptor.DiscCarts(i).Zelev)
                    myFrmMain.frmAnalyse.frmRectable.EFlex1.SetData(myFrmMain.frmAnalyse.frmRectable.EFlex1.Rows.Count - 1, 4, cmbAverageTime.Text)
                    If Me.cmbAverageTime.Text <> "期间平均" Then
                        myFrmMain.frmAnalyse.frmRectable.EFlex1.SetData(myFrmMain.frmAnalyse.frmRectable.EFlex1.Rows.Count - 1, 5, myFrmMain.frmAnalyse.frmResultControl.cmbRectable.Text)
                    End If
                    myFrmMain.frmAnalyse.frmRectable.EFlex1.SetData(myFrmMain.frmAnalyse.frmRectable.EFlex1.Rows.Count - 1, 6, FormatNumber(ResultNameAndData.m_DiscConDEPOS(i).con / 1000, Me.cmbNumber.SelectedIndex)) '设置污染物浓度。由于软件内部采用的单位为ug/m3，要转在mg/m3,应除以1000
                    myFrmMain.frmAnalyse.frmRectable.EFlex1.SetData(myFrmMain.frmAnalyse.frmRectable.EFlex1.Rows.Count - 1, 7, ResultNameAndData.m_DiscConDEPOS(i).dateD)

                    '计算背景浓度。如果关心点没有背景值，采用反距离平方法来计算
                    Backcon = Me.proj.TempAermod.BackCon.PollutBackCon.Item(0).GetBackCon(Me.cmbAverageTime.Text).ListCareBackCon(i).Con
                    If Backcon < 0 And disCarePoint3d.Length > 0 Then
                        Dim Grid3d As New CAermod.Point3D
                        Grid3d.x = Me.proj.TempAermod.Receptor.DiscCarts(i).Xcoord
                        Grid3d.y = Me.proj.TempAermod.Receptor.DiscCarts(i).Ycoord
                        Grid3d.z = Me.proj.TempAermod.Receptor.DiscCarts(i).Zelev + Me.proj.TempAermod.Receptor.DiscCarts(i).Zflag
                        Backcon = CAermod.PublicFunction.GetLocationCon(Grid3d, disCarePoint3d, disCon)
                    ElseIf Backcon < 0 Then
                        Backcon = 0
                    End If

                    myFrmMain.frmAnalyse.frmRectable.EFlex1.SetData(myFrmMain.frmAnalyse.frmRectable.EFlex1.Rows.Count - 1, 8, FormatNumber(Backcon, Me.cmbNumber.SelectedIndex)) '浓度背景值。
                    If cmbAddBackCon.Text = "不叠加" Then
                        myFrmMain.frmAnalyse.frmRectable.EFlex1.SetData(myFrmMain.frmAnalyse.frmRectable.EFlex1.Rows.Count - 1, 9, FormatNumber(ResultNameAndData.m_DiscConDEPOS(i).con / 1000, Me.cmbNumber.SelectedIndex)) '浓度背景值。取最大值
                    Else
                        myFrmMain.frmAnalyse.frmRectable.EFlex1.SetData(myFrmMain.frmAnalyse.frmRectable.EFlex1.Rows.Count - 1, 9, FormatNumber(Backcon + ResultNameAndData.m_DiscConDEPOS(i).con / 1000, Me.cmbNumber.SelectedIndex)) '预测值
                    End If
                    '浓度标准值
                    myFrmMain.frmAnalyse.frmRectable.EFlex1.SetData(myFrmMain.frmAnalyse.frmRectable.EFlex1.Rows.Count - 1, 10, FormatNumber(Me.proj.TempAermod.Control.AllPolluts.AllSelectPollut(0).ConStandard.GetCon(Me.cmbAverageTime.Text), Me.cmbNumber.SelectedIndex)) '浓度背景值。取最大值

                    If cmbAddBackCon.Text = "不叠加" Then
                        myFrmMain.frmAnalyse.frmRectable.EFlex1.SetData(myFrmMain.frmAnalyse.frmRectable.EFlex1.Rows.Count - 1, 11, FormatNumber(100 * (ResultNameAndData.m_DiscConDEPOS(i).con / 1000) / Me.proj.TempAermod.Control.AllPolluts.AllSelectPollut(0).ConStandard.GetCon(Me.cmbAverageTime.Text), Me.cmbNumber.SelectedIndex))
                    Else
                        myFrmMain.frmAnalyse.frmRectable.EFlex1.SetData(myFrmMain.frmAnalyse.frmRectable.EFlex1.Rows.Count - 1, 11, FormatNumber(100 * (Backcon + ResultNameAndData.m_DiscConDEPOS(i).con / 1000) / Me.proj.TempAermod.Control.AllPolluts.AllSelectPollut(0).ConStandard.GetCon(Me.cmbAverageTime.Text), Me.cmbNumber.SelectedIndex))
                    End If
                    If myFrmMain.frmAnalyse.NowProj.TempAermod.Control.AllPolluts.AllSelectPollut(0).Dispersion.DEPOS = True Then
                        myFrmMain.frmAnalyse.frmRectable.EFlex1.SetData(myFrmMain.frmAnalyse.frmRectable.EFlex1.Rows.Count - 1, 12, FormatNumber(ResultNameAndData.m_DiscConDEPOS(i).DEPOS, Me.cmbNumber.SelectedIndex)) '设置总沉积。由于软件内部采用的单位为ug/m3，要转在mg/m3,应除以1000
                        myFrmMain.frmAnalyse.frmRectable.EFlex1.SetData(myFrmMain.frmAnalyse.frmRectable.EFlex1.Rows.Count - 1, 13, FormatNumber(ResultNameAndData.m_DiscConDEPOS(i).DDEP, Me.cmbNumber.SelectedIndex)) '设置干沉积。由于软件内部采用的单位为ug/m3，要转在mg/m3,应除以1000
                        myFrmMain.frmAnalyse.frmRectable.EFlex1.SetData(myFrmMain.frmAnalyse.frmRectable.EFlex1.Rows.Count - 1, 14, FormatNumber(ResultNameAndData.m_DiscConDEPOS(i).WDEP, Me.cmbNumber.SelectedIndex)) '设置湿沉积。由于软件内部采用的单位为ug/m3，要转在mg/m3,应除以1000

                    End If
                End If
            Next

            '所有计算点的最大值
            myFrmMain.frmAnalyse.frmRectable.EFlex1.Rows.Count += 1
            myFrmMain.frmAnalyse.frmRectable.EFlex1.SetData(myFrmMain.frmAnalyse.frmRectable.EFlex1.Rows.Count - 1, 1, Me.proj.TempAermod.Control.AllPolluts.AllSelectPollut(0).Name)
            myFrmMain.frmAnalyse.frmRectable.EFlex1.SetData(myFrmMain.frmAnalyse.frmRectable.EFlex1.Rows.Count - 1, 2, "区域最大值")
            myFrmMain.frmAnalyse.frmRectable.EFlex1.SetData(myFrmMain.frmAnalyse.frmRectable.EFlex1.Rows.Count - 1, 3, ResultNameAndData.m_MaxValueConDEPOS.x & "," & ResultNameAndData.m_MaxValueConDEPOS.y & "," & ResultNameAndData.m_MaxValueConDEPOS.z)
            myFrmMain.frmAnalyse.frmRectable.EFlex1.SetData(myFrmMain.frmAnalyse.frmRectable.EFlex1.Rows.Count - 1, 4, Me.cmbAverageTime.Text)
            If Me.cmbAverageTime.Text <> "期间平均" Then
                myFrmMain.frmAnalyse.frmRectable.EFlex1.SetData(myFrmMain.frmAnalyse.frmRectable.EFlex1.Rows.Count - 1, 5, myFrmMain.frmAnalyse.frmResultControl.cmbRectable.Text)
            End If
            myFrmMain.frmAnalyse.frmRectable.EFlex1.SetData(myFrmMain.frmAnalyse.frmRectable.EFlex1.Rows.Count - 1, 6, FormatNumber(ResultNameAndData.m_MaxValueConDEPOS.con / 1000, Me.cmbNumber.SelectedIndex)) '设置污染物浓度。由于软件内部采用的单位为ug/m3，要转在mg/m3,应除以1000
            myFrmMain.frmAnalyse.frmRectable.EFlex1.SetData(myFrmMain.frmAnalyse.frmRectable.EFlex1.Rows.Count - 1, 7, ResultNameAndData.m_MaxValueConDEPOS.dateD)
            '背景浓度
            Backcon = Me.proj.TempAermod.BackCon.PollutBackCon.Item(0).GetBackCon(Me.cmbAverageTime.Text).AervaggeCon  '区域平均浓度
            myFrmMain.frmAnalyse.frmRectable.EFlex1.SetData(myFrmMain.frmAnalyse.frmRectable.EFlex1.Rows.Count - 1, 8, FormatNumber(Backcon, Me.cmbNumber.SelectedIndex)) '浓度背景值。
            If cmbAddBackCon.Text = "不叠加" Then
                myFrmMain.frmAnalyse.frmRectable.EFlex1.SetData(myFrmMain.frmAnalyse.frmRectable.EFlex1.Rows.Count - 1, 9, FormatNumber(ResultNameAndData.m_MaxValueConDEPOS.con / 1000, Me.cmbNumber.SelectedIndex)) '浓度背景值。取最大值
            Else
                myFrmMain.frmAnalyse.frmRectable.EFlex1.SetData(myFrmMain.frmAnalyse.frmRectable.EFlex1.Rows.Count - 1, 9, FormatNumber(Backcon + ResultNameAndData.m_MaxValueConDEPOS.con / 1000, Me.cmbNumber.SelectedIndex)) '预测值
            End If
            '浓度标准值
            myFrmMain.frmAnalyse.frmRectable.EFlex1.SetData(myFrmMain.frmAnalyse.frmRectable.EFlex1.Rows.Count - 1, 10, FormatNumber(Me.proj.TempAermod.Control.AllPolluts.AllSelectPollut(0).ConStandard.GetCon(Me.cmbAverageTime.Text), Me.cmbNumber.SelectedIndex)) '浓度背景值。取最大值

            If cmbAddBackCon.Text = "不叠加" Then
                myFrmMain.frmAnalyse.frmRectable.EFlex1.SetData(myFrmMain.frmAnalyse.frmRectable.EFlex1.Rows.Count - 1, 11, FormatNumber(100 * (ResultNameAndData.m_MaxValueConDEPOS.con / 1000) / Me.proj.TempAermod.Control.AllPolluts.AllSelectPollut(0).ConStandard.GetCon(Me.cmbAverageTime.Text), Me.cmbNumber.SelectedIndex))
            Else
                myFrmMain.frmAnalyse.frmRectable.EFlex1.SetData(myFrmMain.frmAnalyse.frmRectable.EFlex1.Rows.Count - 1, 11, FormatNumber(100 * (Backcon + ResultNameAndData.m_MaxValueConDEPOS.con / 1000) / Me.proj.TempAermod.Control.AllPolluts.AllSelectPollut(0).ConStandard.GetCon(Me.cmbAverageTime.Text), Me.cmbNumber.SelectedIndex))
            End If
            If myFrmMain.frmAnalyse.NowProj.TempAermod.Control.AllPolluts.AllSelectPollut(0).Dispersion.DEPOS = True Then
                myFrmMain.frmAnalyse.frmRectable.EFlex1.SetData(myFrmMain.frmAnalyse.frmRectable.EFlex1.Rows.Count - 1, 12, FormatNumber(ResultNameAndData.m_MaxValueConDEPOS.DEPOS, Me.cmbNumber.SelectedIndex)) '设置总沉积。由于软件内部采用的单位为ug/m3，要转在mg/m3,应除以1000
                myFrmMain.frmAnalyse.frmRectable.EFlex1.SetData(myFrmMain.frmAnalyse.frmRectable.EFlex1.Rows.Count - 1, 13, FormatNumber(ResultNameAndData.m_MaxValueConDEPOS.DDEP, Me.cmbNumber.SelectedIndex)) '设置干沉积。由于软件内部采用的单位为ug/m3，要转在mg/m3,应除以1000
                myFrmMain.frmAnalyse.frmRectable.EFlex1.SetData(myFrmMain.frmAnalyse.frmRectable.EFlex1.Rows.Count - 1, 14, FormatNumber(ResultNameAndData.m_MaxValueConDEPOS.WDEP, Me.cmbNumber.SelectedIndex)) '设置湿沉积。由于软件内部采用的单位为ug/m3，要转在mg/m3,应除以1000

            End If
            myFrmMain.frmAnalyse.frmRectable.EFlex1.AutoSizeCols()
            myFrmMain.frmAnalyse.Refresh()
            ''GIS绘图-----------------------------------
        Catch ex As Exception
            MessageBox.Show("预测方案可能已经被改变，请重新计算!")
        End Try

    End Sub
#End Region

#Region "逐步值文件"
    Private Sub GetDataFromPostFileAndShow()
        Dim MyMainFrm As frmMain = My.Application.ApplicationContext.MainForm
        Dim SaveContourFileName As String = ""
        If Me.cmbGroups.SelectedIndex >= 0 And Me.cmbAverageTime.SelectedIndex >= 0 _
                                    And Me.cmbGrid.SelectedIndex >= 0 And Me.lstTime.SelectedIndex >= 0 Then
            Dim FileName As String
            Dim Path As String = System.IO.Path.GetDirectoryName(AermodProject0.SaveName) & "\" & CAermod.GetFileName(AermodProject0.SaveName)
            FileName = Path & "\Aermod\" _
            & Me.proj.ID & "\" & Me.proj.TempAermod.Source.Groups.ArrayGroup(Me.cmbGroups.SelectedIndex).GroupID & "_POST_" _
            & Me.proj.TempAermod.Control.AerageingTime.GetSelectedAerageingTime(Me.cmbAverageTime.SelectedIndex).ToString & ".BIN"
            Dim PostData As New CAermod.PostResult20


            Dim OnePost As CAermod.PostFineBinResult = PostData.GetDataPostBin(Me.proj.TempAermod.Control, Me.proj.TempAermod.Receptor, Me.proj.TempAermod.Control.AllPolluts.AllSelectPollut(0).Dispersion.DEPOS, Me.lstTime.SelectedIndex, FileName, "09292")

            Dim Grid(Me.proj.TempAermod.Receptor.SubGridCart(Me.cmbGrid.SelectedIndex).Ynum - 1, Me.proj.TempAermod.Receptor.SubGridCart(Me.cmbGrid.SelectedIndex).Xnum - 1) As Double
            SaveContourFileName = CAermod.GetFileName(FileName) & "_" & Me.proj.TempAermod.Receptor.SubGridCart(Me.cmbGrid.SelectedIndex).Netid & "_" & Me.lstTime.SelectedIndex

            Select Case Me.cmbCon.Text
                Case "浓度"
                    For i As Integer = 0 To Me.proj.TempAermod.Receptor.SubGridCart(Me.cmbGrid.SelectedIndex).Ynum - 1
                        For j As Integer = 0 To Me.proj.TempAermod.Receptor.SubGridCart(Me.cmbGrid.SelectedIndex).Xnum - 1
                            Grid(i, j) = OnePost.m_SubGridData(Me.cmbGrid.SelectedIndex)(i, j).con / 1000
                        Next
                    Next
                    '获取背景浓度的数组
                    Dim disCarePoint3d(-1) As CAermod.Point3D
                    Dim disCon(-1) As Double
                    For j As Integer = 0 To Me.proj.TempAermod.Receptor.DiscCarts.Length - 1
                        If Me.proj.TempAermod.BackCon.PollutBackCon.Item(0).GetBackCon(Me.cmbAverageTime.Text).ListCareBackCon(j).Con >= 0 Then
                            ReDim Preserve disCarePoint3d(disCarePoint3d.Length)
                            ReDim Preserve disCon(disCon.Length)
                            disCarePoint3d(disCarePoint3d.Length - 1) = New CAermod.Point3D
                            disCarePoint3d(disCarePoint3d.Length - 1).x = Me.proj.TempAermod.Receptor.DiscCarts(j).Xcoord
                            disCarePoint3d(disCarePoint3d.Length - 1).y = Me.proj.TempAermod.Receptor.DiscCarts(j).Ycoord
                            disCarePoint3d(disCarePoint3d.Length - 1).z = Me.proj.TempAermod.Receptor.DiscCarts(j).Zelev
                            disCon(disCarePoint3d.Length - 1) = Me.proj.TempAermod.BackCon.PollutBackCon.Item(0).GetBackCon(Me.cmbAverageTime.Text).ListCareBackCon(j).Con
                        End If
                    Next
                    SaveContourFileName = SaveContourFileName & "_Con"


                    If Me.cmbAddBackCon.Text = "叠加" And disCarePoint3d.Length > 0 Then '如果叠加背景值，采用反距离平方法求得每个网格点的背景值

                        Dim Backcon As Double
                        For i As Integer = 0 To Me.proj.TempAermod.Receptor.SubGridCart(Me.cmbGrid.SelectedIndex).Ynum - 1
                            For j As Integer = 0 To Me.proj.TempAermod.Receptor.SubGridCart(Me.cmbGrid.SelectedIndex).Xnum - 1

                                If disCarePoint3d.Length > 0 Then
                                    Dim Grid3d As New CAermod.Point3D
                                    Grid3d.x = OnePost.m_SubGridData(Me.cmbGrid.SelectedIndex)(i, j).x
                                    Grid3d.y = OnePost.m_SubGridData(Me.cmbGrid.SelectedIndex)(i, j).y
                                    Grid3d.z = Me.proj.TempAermod.Receptor.SubGridCart(Me.cmbGrid.SelectedIndex).Elev(i)(j)
                                    Backcon = CAermod.PublicFunction.GetLocationCon(Grid3d, disCarePoint3d, disCon)
                                ElseIf Backcon < 0 Then
                                    Backcon = 0
                                End If
                                Grid(i, j) = OnePost.m_SubGridData(Me.cmbGrid.SelectedIndex)(i, j).con / 1000 + Backcon
                            Next
                        Next
                        SaveContourFileName = SaveContourFileName & "_Con" & "_Add"
                    End If
                Case "总沉积"
                    For i As Integer = 0 To Me.proj.TempAermod.Receptor.SubGridCart(Me.cmbGrid.SelectedIndex).Ynum - 1
                        For j As Integer = 0 To Me.proj.TempAermod.Receptor.SubGridCart(Me.cmbGrid.SelectedIndex).Xnum - 1
                            Grid(i, j) = OnePost.m_SubGridData(Me.cmbGrid.SelectedIndex)(i, j).DEPOS
                        Next
                    Next
                    SaveContourFileName = SaveContourFileName & "_DEPOS"

                Case "干沉积"
                    For i As Integer = 0 To Me.proj.TempAermod.Receptor.SubGridCart(Me.cmbGrid.SelectedIndex).Ynum - 1
                        For j As Integer = 0 To Me.proj.TempAermod.Receptor.SubGridCart(Me.cmbGrid.SelectedIndex).Xnum - 1
                            Grid(i, j) = OnePost.m_SubGridData(Me.cmbGrid.SelectedIndex)(i, j).DDEP
                        Next
                    Next
                    SaveContourFileName = SaveContourFileName & "_DDEP"

                Case "湿沉积"
                    For i As Integer = 0 To Me.proj.TempAermod.Receptor.SubGridCart(Me.cmbGrid.SelectedIndex).Ynum - 1
                        For j As Integer = 0 To Me.proj.TempAermod.Receptor.SubGridCart(Me.cmbGrid.SelectedIndex).Xnum - 1
                            Grid(i, j) = OnePost.m_SubGridData(Me.cmbGrid.SelectedIndex)(i, j).WDEP
                        Next
                    Next
                    SaveContourFileName = SaveContourFileName & "_WDEP"

            End Select
            '用于保存等值线的文件的名称
            ChangeContours(Grid, Me.proj.TempAermod.Receptor.SubGridCart(Me.cmbGrid.SelectedIndex).Xinit, Me.proj.TempAermod.Receptor.SubGridCart(Me.cmbGrid.SelectedIndex).Xdelta, Me.proj.TempAermod.Receptor.SubGridCart(Me.cmbGrid.SelectedIndex).Xnum _
                           , Me.proj.TempAermod.Receptor.SubGridCart(Me.cmbGrid.SelectedIndex).Yinit, Me.proj.TempAermod.Receptor.SubGridCart(Me.cmbGrid.SelectedIndex).Ydelta, Me.proj.TempAermod.Receptor.SubGridCart(Me.cmbGrid.SelectedIndex).Ynum _
                          , AermodProject0.GetOffsetX, AermodProject0.GetOffsetY, SaveContourFileName, True)

            ShowPostToCareTable(OnePost)
        End If
    End Sub

    ''' <summary>
    ''' 在表中显示关心点的数据
    ''' </summary>
    ''' <param name="OnePost">一个post记录</param>
    ''' <remarks></remarks>
    Private Sub ShowPostToCareTable(ByRef OnePost As CAermod.PostFineBinResult)
        Try
            Dim myFrmMain As frmMain = My.Application.ApplicationContext.MainForm
            myFrmMain.frmAnalyse.frmRectable.EFlex1.Rows.Count = 1
            '设置列数及行标题
            myFrmMain.frmAnalyse.frmRectable.EFlex1.Cols.Count = 14
            myFrmMain.frmAnalyse.frmRectable.EFlex1.AllowSorting = C1.Win.C1FlexGrid.AllowSortingEnum.None
            myFrmMain.frmAnalyse.frmRectable.EFlex1.AllowResizing = C1.Win.C1FlexGrid.AllowResizingEnum.Columns
            myFrmMain.frmAnalyse.frmRectable.EFlex1.AllowDragging = C1.Win.C1FlexGrid.AllowDraggingEnum.None
            myFrmMain.frmAnalyse.frmRectable.EFlex1.AllowMerging = C1.Win.C1FlexGrid.AllowMergingEnum.Free
            For i As Integer = 0 To 2
                myFrmMain.frmAnalyse.frmRectable.EFlex1.Cols(i).AllowMerging = True
            Next
            myFrmMain.frmAnalyse.frmRectable.EFlex1.SetData(0, 0, "序号")
            myFrmMain.frmAnalyse.frmRectable.EFlex1.SetData(0, 1, "污染物名称")
            myFrmMain.frmAnalyse.frmRectable.EFlex1.SetData(0, 2, "关心点")
            myFrmMain.frmAnalyse.frmRectable.EFlex1.SetData(0, 3, "坐标[x,y,z]")
            myFrmMain.frmAnalyse.frmRectable.EFlex1.SetData(0, 4, "平均时间")
            myFrmMain.frmAnalyse.frmRectable.EFlex1.SetData(0, 5, "浓度值[mg/m^3]")
            myFrmMain.frmAnalyse.frmRectable.EFlex1.SetData(0, 6, "出现时刻")
            myFrmMain.frmAnalyse.frmRectable.EFlex1.SetData(0, 7, "背景值[mg/m^3]")
            myFrmMain.frmAnalyse.frmRectable.EFlex1.SetData(0, 8, "预测值[mg/m^3]")
            myFrmMain.frmAnalyse.frmRectable.EFlex1.SetData(0, 9, "标准值")
            myFrmMain.frmAnalyse.frmRectable.EFlex1.SetData(0, 10, "占标率[%]")
            If myFrmMain.frmAnalyse.NowProj.TempAermod.Control.AllPolluts.AllSelectPollut(0).Dispersion.DEPOS = True Then
                myFrmMain.frmAnalyse.frmRectable.EFlex1.SetData(0, 11, "总沉积[g/m^2]")
                myFrmMain.frmAnalyse.frmRectable.EFlex1.SetData(0, 12, "干沉积[g/m^2]")
                myFrmMain.frmAnalyse.frmRectable.EFlex1.SetData(0, 13, "湿沉积[g/m^2]")

            End If

            myFrmMain.frmAnalyse.frmRectable.EFlex1.AutoSizeCols()


            '获取背景浓度的数组
            Dim disCarePoint3d(-1) As CAermod.Point3D
            Dim disCon(-1) As Double
            For j As Integer = 0 To Me.proj.TempAermod.Receptor.DiscCarts.Length - 1
                If Me.proj.TempAermod.BackCon.PollutBackCon.Item(0).GetBackCon(Me.cmbAverageTime.Text).ListCareBackCon(j).Con >= 0 Then
                    ReDim Preserve disCarePoint3d(disCarePoint3d.Length)
                    ReDim Preserve disCon(disCon.Length)
                    disCarePoint3d(disCarePoint3d.Length - 1) = New CAermod.Point3D
                    disCarePoint3d(disCarePoint3d.Length - 1).x = Me.proj.TempAermod.Receptor.DiscCarts(j).Xcoord
                    disCarePoint3d(disCarePoint3d.Length - 1).y = Me.proj.TempAermod.Receptor.DiscCarts(j).Ycoord
                    disCarePoint3d(disCarePoint3d.Length - 1).z = Me.proj.TempAermod.Receptor.DiscCarts(j).Zelev
                    disCon(disCarePoint3d.Length - 1) = Me.proj.TempAermod.BackCon.PollutBackCon.Item(0).GetBackCon(Me.cmbAverageTime.Text).ListCareBackCon(j).Con
                End If
            Next
            Dim Backcon As Double
            '设置表格的行数=（关心点个数+1）*输出的最大浓度的个数
            myFrmMain.frmAnalyse.frmRectable.EFlex1.Rows.Count = 1
            For i As Integer = 0 To Me.proj.TempAermod.Receptor.DiscCarts.Length - 1
                myFrmMain.frmAnalyse.frmRectable.EFlex1.Rows.Count += 1
                myFrmMain.frmAnalyse.frmRectable.EFlex1.SetData(myFrmMain.frmAnalyse.frmRectable.EFlex1.Rows.Count - 1, 1, Me.proj.TempAermod.Control.AllPolluts.AllSelectPollut(0).Name)
                myFrmMain.frmAnalyse.frmRectable.EFlex1.SetData(myFrmMain.frmAnalyse.frmRectable.EFlex1.Rows.Count - 1, 2, Me.proj.TempAermod.Receptor.DiscCarts(i).Name)
                myFrmMain.frmAnalyse.frmRectable.EFlex1.SetData(myFrmMain.frmAnalyse.frmRectable.EFlex1.Rows.Count - 1, 3, Me.proj.TempAermod.Receptor.DiscCarts(i).Xcoord & "," & Me.proj.TempAermod.Receptor.DiscCarts(i).Ycoord & "," & Me.proj.TempAermod.Receptor.DiscCarts(i).Zelev)
                myFrmMain.frmAnalyse.frmRectable.EFlex1.SetData(myFrmMain.frmAnalyse.frmRectable.EFlex1.Rows.Count - 1, 4, cmbAverageTime.Text)
                myFrmMain.frmAnalyse.frmRectable.EFlex1.SetData(myFrmMain.frmAnalyse.frmRectable.EFlex1.Rows.Count - 1, 5, FormatNumber(OnePost.m_CareData(i).con / 1000, Me.cmbNumber.SelectedIndex)) '设置污染物浓度。由于软件内部采用的单位为ug/m3，要转在mg/m3,应除以1000
                myFrmMain.frmAnalyse.frmRectable.EFlex1.SetData(myFrmMain.frmAnalyse.frmRectable.EFlex1.Rows.Count - 1, 6, OnePost.m_dateD)

                '计算背景浓度。如果关心点没有背景值，采用反距离平方法来计算
                Backcon = Me.proj.TempAermod.BackCon.PollutBackCon.Item(0).GetBackCon(Me.cmbAverageTime.Text).ListCareBackCon(i).Con
                If Backcon < 0 And disCarePoint3d.Length > 0 Then
                    Dim Grid3d As New CAermod.Point3D
                    Grid3d.x = Me.proj.TempAermod.Receptor.DiscCarts(i).Xcoord
                    Grid3d.y = Me.proj.TempAermod.Receptor.DiscCarts(i).Ycoord
                    Grid3d.z = Me.proj.TempAermod.Receptor.DiscCarts(i).Zelev + Me.proj.TempAermod.Receptor.DiscCarts(i).Zflag
                    Backcon = CAermod.PublicFunction.GetLocationCon(Grid3d, disCarePoint3d, disCon)
                ElseIf Backcon < 0 Then
                    Backcon = 0
                End If

                myFrmMain.frmAnalyse.frmRectable.EFlex1.SetData(myFrmMain.frmAnalyse.frmRectable.EFlex1.Rows.Count - 1, 7, FormatNumber(Backcon, Me.cmbNumber.SelectedIndex)) '浓度背景值。
                If cmbAddBackCon.Text = "不叠加" Then
                    myFrmMain.frmAnalyse.frmRectable.EFlex1.SetData(myFrmMain.frmAnalyse.frmRectable.EFlex1.Rows.Count - 1, 8, FormatNumber(OnePost.m_CareData(i).con / 1000, Me.cmbNumber.SelectedIndex)) '浓度背景值。取最大值
                Else
                    myFrmMain.frmAnalyse.frmRectable.EFlex1.SetData(myFrmMain.frmAnalyse.frmRectable.EFlex1.Rows.Count - 1, 8, FormatNumber(Backcon + OnePost.m_CareData(i).con / 1000, Me.cmbNumber.SelectedIndex)) '预测值
                End If
                '浓度标准值
                myFrmMain.frmAnalyse.frmRectable.EFlex1.SetData(myFrmMain.frmAnalyse.frmRectable.EFlex1.Rows.Count - 1, 9, FormatNumber(Me.proj.TempAermod.Control.AllPolluts.AllSelectPollut(0).ConStandard.GetCon(Me.cmbAverageTime.Text), Me.cmbNumber.SelectedIndex)) '浓度背景值。取最大值

                If cmbAddBackCon.Text = "不叠加" Then
                    myFrmMain.frmAnalyse.frmRectable.EFlex1.SetData(myFrmMain.frmAnalyse.frmRectable.EFlex1.Rows.Count - 1, 10, FormatNumber(100 * (OnePost.m_CareData(i).con / 1000) / Me.proj.TempAermod.Control.AllPolluts.AllSelectPollut(0).ConStandard.GetCon(Me.cmbAverageTime.Text), Me.cmbNumber.SelectedIndex))
                Else
                    myFrmMain.frmAnalyse.frmRectable.EFlex1.SetData(myFrmMain.frmAnalyse.frmRectable.EFlex1.Rows.Count - 1, 10, FormatNumber(100 * (Backcon + OnePost.m_CareData(i).con / 1000) / Me.proj.TempAermod.Control.AllPolluts.AllSelectPollut(0).ConStandard.GetCon(Me.cmbAverageTime.Text), Me.cmbNumber.SelectedIndex))
                End If
                If myFrmMain.frmAnalyse.NowProj.TempAermod.Control.AllPolluts.AllSelectPollut(0).Dispersion.DEPOS = True Then
                    myFrmMain.frmAnalyse.frmRectable.EFlex1.SetData(myFrmMain.frmAnalyse.frmRectable.EFlex1.Rows.Count - 1, 11, FormatNumber(OnePost.m_CareData(i).DEPOS, Me.cmbNumber.SelectedIndex)) '设置总沉积。由于软件内部采用的单位为ug/m3，要转在mg/m3,应除以1000
                    myFrmMain.frmAnalyse.frmRectable.EFlex1.SetData(myFrmMain.frmAnalyse.frmRectable.EFlex1.Rows.Count - 1, 12, FormatNumber(OnePost.m_CareData(i).DDEP, Me.cmbNumber.SelectedIndex)) '设置干沉积。由于软件内部采用的单位为ug/m3，要转在mg/m3,应除以1000
                    myFrmMain.frmAnalyse.frmRectable.EFlex1.SetData(myFrmMain.frmAnalyse.frmRectable.EFlex1.Rows.Count - 1, 13, FormatNumber(OnePost.m_CareData(i).WDEP, Me.cmbNumber.SelectedIndex)) '设置湿沉积。由于软件内部采用的单位为ug/m3，要转在mg/m3,应除以1000

                End If


            Next
            myFrmMain.frmAnalyse.frmRectable.EFlex1.AutoSizeCols()
            myFrmMain.frmAnalyse.Refresh()
            ''GIS绘图-----------------------------------
        Catch ex As Exception
            MessageBox.Show("预测方案可能已经被改变，请重新计算!")
        End Try

    End Sub
#End Region

    Private Sub IntialTime()
        Dim MyMainFrm As frmMain = My.Application.ApplicationContext.MainForm
        If Me.cmbGroups.SelectedIndex >= 0 And Me.cmbAverageTime.SelectedIndex >= 0 Then

            Dim FileName As String
            Dim Path As String = System.IO.Path.GetDirectoryName(AermodProject0.SaveName) & "\" & CAermod.GetFileName(AermodProject0.SaveName)
            FileName = Path & "\Aermod\" _
            & Me.proj.ID & "\" & Me.proj.TempAermod.Source.Groups.ArrayGroup(Me.cmbGroups.SelectedIndex).GroupID & "_POST_" _
            & Me.proj.TempAermod.Control.AerageingTime.GetSelectedAerageingTime(Me.cmbAverageTime.SelectedIndex).ToString & ".BIN"
            Dim PostData As New CAermod.PostResult20
            With Me.proj.TempAermod
                Dim nCount As Integer
                '先找出总的数据记录的个数
                Dim Post As New CAermod.PostResult20
                nCount = Post.GetDataCount(.Control, .Receptor, .Control.AllPolluts.AllSelectPollut(0).Dispersion.DEPOS, FileName, "09292")
                Dim strFirsTime As String = Post.GetFirstTime(FileName)
                Dim FistTime As DateTime = Post.StringToDate(strFirsTime)
                '把所有时间列表出来
                Me.lstTime.Items.Clear()
                Select Case .Control.AerageingTime.GetSelectedAerageingTime(Me.cmbAverageTime.SelectedIndex).ToUpper
                    Case "1h".ToUpper
                        For kTime As Integer = 0 To nCount - 1
                            Dim AddTime As New DateTime
                            AddTime = FistTime.AddHours(1 * kTime)
                            Me.lstTime.Items.Add(AddTime.ToString)
                        Next
                    Case "2h".ToUpper
                        For kTime As Integer = 0 To nCount - 1
                            Dim AddTime As New DateTime
                            AddTime = FistTime.AddHours(2 * kTime)
                            Me.lstTime.Items.Add(AddTime.ToString)
                        Next
                    Case "3h".ToUpper
                        For kTime As Integer = 0 To nCount - 1
                            Dim AddTime As New DateTime
                            AddTime = FistTime.AddHours(3 * kTime)
                            Me.lstTime.Items.Add(AddTime.ToString)
                        Next
                    Case "4h".ToUpper
                        For kTime As Integer = 0 To nCount - 1
                            Dim AddTime As New DateTime
                            AddTime = FistTime.AddHours(4 * kTime)
                            Me.lstTime.Items.Add(AddTime.ToString)
                        Next
                    Case "6h".ToUpper
                        For kTime As Integer = 0 To nCount - 1
                            Dim AddTime As New DateTime
                            AddTime = FistTime.AddHours(6 * kTime)
                            Me.lstTime.Items.Add(AddTime.ToString)
                        Next
                    Case "8h".ToUpper
                        For kTime As Integer = 0 To nCount - 1
                            Dim AddTime As New DateTime
                            AddTime = FistTime.AddHours(8 * kTime)
                            Me.lstTime.Items.Add(AddTime.ToString)
                        Next
                    Case "12h".ToUpper
                        For kTime As Integer = 0 To nCount - 1
                            Dim AddTime As New DateTime
                            AddTime = FistTime.AddHours(12 * kTime)
                            Me.lstTime.Items.Add(AddTime.ToString)
                        Next
                    Case "24h".ToUpper
                        For kTime As Integer = 0 To nCount - 1
                            Dim AddTime As New DateTime
                            AddTime = FistTime.AddDays(1 * (kTime - 1))
                            Me.lstTime.Items.Add(AddTime.ToString.Remove(AddTime.ToString.Length - 8, 8))
                        Next
                    Case "月平均"
                        For kTime As Integer = 0 To nCount - 1
                            Dim AddTime As New DateTime
                            AddTime = FistTime.AddMonths(1 * kTime)
                            Me.lstTime.Items.Add(AddTime.ToString)
                        Next
                End Select
                If Me.lstTime.Items.Count > 0 Then
                    Me.lstTime.SelectedIndex = 0
                End If
            End With
        End If
    End Sub
#Region "显示所有点最大值"
    ''' <summary>
    ''' 显示所有点最大值
    ''' </summary>
    ''' <remarks></remarks>
    Private Sub GetDataFromMaxFileAndShow()
        Try

            Dim myFrmMain As frmMain = My.Application.ApplicationContext.MainForm
            Dim jIndexAverageTime As Integer = cmbAverageTime.SelectedIndex
            Dim nGroup As Integer = cmbGroups.SelectedIndex
            Dim MaxData As New CAermod.MaxTalbeResult

            If Me.cmbGroups.SelectedIndex >= 0 And Me.cmbAverageTime.SelectedIndex >= 0 And Me.cmbAverageTime.Text <> "期间平均" Then
                Dim FileName As String
                Dim Path As String = System.IO.Path.GetDirectoryName(AermodProject0.SaveName) & "\" & CAermod.GetFileName(AermodProject0.SaveName)
                FileName = Path & "\Aermod\" & Me.proj.ID & "\" & Me.proj.TempAermod.Control.AllPolluts.AllSelectPollut(0).Name & "_输出文件.OUT"
                Dim AllSlelectedCount As Integer = Me.proj.TempAermod.Source.Groups.ArrayGroup(Me.cmbGroups.SelectedIndex).GetAllSlelectedCount(Me.proj.TempAermod.Source, Me.proj.TempAermod.Control.AllPolluts.AllSelectPollut(0).Name)
                If Me.cmbAverageTime.Text = "月平均" Then
                    MaxData.GetMaxTalbeDateFromAERMODOUT(FileName, Me.proj.TempAermod.OutPutOption _
                                                                                            , Me.proj.TempAermod.Control.AllPolluts.AllSelectPollut(0).Dispersion.DEPOS _
                                                                                            , Me.proj.TempAermod.Control.AerageingTime.GetSelectedAerageingTimeToAREMOD(Me.cmbAverageTime.SelectedIndex).ToString _
                                                                                            , Me.proj.TempAermod.Source.Groups.ArrayGroup(Me.cmbGroups.SelectedIndex).GroupID _
                                                                                            , AllSlelectedCount, "09292")
                Else
                    MaxData.GetMaxTalbeDateFromAERMODOUT(FileName, Me.proj.TempAermod.OutPutOption _
                                                                         , Me.proj.TempAermod.Control.AllPolluts.AllSelectPollut(0).Dispersion.DEPOS _
                                                                         , Me.proj.TempAermod.Control.AerageingTime.GetSelectedAerageingTimeToAREMOD(Me.cmbAverageTime.SelectedIndex).ToString & "-HR" _
                                                                         , Me.proj.TempAermod.Source.Groups.ArrayGroup(Me.cmbGroups.SelectedIndex).GroupID _
                                                                         , AllSlelectedCount, "09292")
                End If


                '期间平均的所有点最大值通过期间平均的各点高值来求得
            ElseIf Me.cmbAverageTime.Text = "期间平均" Then
                Dim ResultNameAndData As New CAermod.ResultNameAndData
                Dim FileName As String = ""
                GetDataFromPlotFile(ResultNameAndData, FileName)

                ReDim MaxData.MaxCon(-1) '浓度
                ReDim MaxData.MaxDEPOS(-1) '总沉积
                ReDim MaxData.MaxDDEP(-1) '干沉积
                ReDim MaxData.MaxWDEP(-1) '湿沉积

                '---------------------------------------------------------------------------------------
                '浓度
                '---------------------------------------------------------------------------------------
                For i As Integer = 0 To ResultNameAndData.m_SubGridConDEPOS.Length - 1
                    If ResultNameAndData.m_SubGridConDEPOS(i) IsNot Nothing Then
                        For k As Integer = 0 To ResultNameAndData.m_SubGridConDEPOS(i).GetLength(0) - 1
                            For L As Integer = 0 To ResultNameAndData.m_SubGridConDEPOS(i).GetLength(1) - 1
                                ReDim Preserve MaxData.MaxCon(MaxData.MaxCon.Length)
                                ReDim Preserve MaxData.MaxDEPOS(MaxData.MaxDEPOS.Length)
                                ReDim Preserve MaxData.MaxDDEP(MaxData.MaxDDEP.Length)
                                ReDim Preserve MaxData.MaxWDEP(MaxData.MaxWDEP.Length)
                                MaxData.MaxCon(MaxData.MaxCon.Length - 1) = New CAermod.ResultCon
                                MaxData.MaxDEPOS(MaxData.MaxDEPOS.Length - 1) = New CAermod.ResultDEPOS
                                MaxData.MaxDDEP(MaxData.MaxDDEP.Length - 1) = New CAermod.ResultDDEP
                                MaxData.MaxWDEP(MaxData.MaxWDEP.Length - 1) = New CAermod.ResultWDEP
                                MaxData.MaxCon(MaxData.MaxCon.Length - 1).con = ResultNameAndData.m_SubGridConDEPOS(i)(k, L).con
                                MaxData.MaxDEPOS(MaxData.MaxDEPOS.Length - 1).DEPOS = ResultNameAndData.m_SubGridConDEPOS(i)(k, L).DEPOS
                                MaxData.MaxDDEP(MaxData.MaxDDEP.Length - 1).DDEP = ResultNameAndData.m_SubGridConDEPOS(i)(k, L).DDEP
                                MaxData.MaxWDEP(MaxData.MaxWDEP.Length - 1).WDEP = ResultNameAndData.m_SubGridConDEPOS(i)(k, L).WDEP

                                MaxData.MaxCon(MaxData.MaxCon.Length - 1).x = ResultNameAndData.m_SubGridConDEPOS(i)(k, L).x
                                MaxData.MaxCon(MaxData.MaxCon.Length - 1).y = ResultNameAndData.m_SubGridConDEPOS(i)(k, L).y
                            Next
                        Next
                    End If
                Next
                For i As Integer = 0 To ResultNameAndData.m_DiscConDEPOS.Length - 1
                    If ResultNameAndData.m_DiscConDEPOS IsNot Nothing Then
                        ReDim Preserve MaxData.MaxCon(MaxData.MaxCon.Length)
                        ReDim Preserve MaxData.MaxDEPOS(MaxData.MaxDEPOS.Length)
                        ReDim Preserve MaxData.MaxDDEP(MaxData.MaxDDEP.Length)
                        ReDim Preserve MaxData.MaxWDEP(MaxData.MaxWDEP.Length)
                        MaxData.MaxDEPOS(MaxData.MaxDEPOS.Length - 1) = New CAermod.ResultDEPOS
                        MaxData.MaxDDEP(MaxData.MaxDDEP.Length - 1) = New CAermod.ResultDDEP
                        MaxData.MaxWDEP(MaxData.MaxWDEP.Length - 1) = New CAermod.ResultWDEP
                        MaxData.MaxCon(MaxData.MaxCon.Length - 1) = New CAermod.ResultCon
                        MaxData.MaxCon(MaxData.MaxCon.Length - 1).con = ResultNameAndData.m_DiscConDEPOS(i).con
                        MaxData.MaxDEPOS(MaxData.MaxDEPOS.Length - 1).DEPOS = ResultNameAndData.m_DiscConDEPOS(i).DEPOS
                        MaxData.MaxDDEP(MaxData.MaxDDEP.Length - 1).DDEP = ResultNameAndData.m_DiscConDEPOS(i).DDEP
                        MaxData.MaxWDEP(MaxData.MaxWDEP.Length - 1).WDEP = ResultNameAndData.m_DiscConDEPOS(i).WDEP
                        MaxData.MaxCon(MaxData.MaxCon.Length - 1).x = ResultNameAndData.m_DiscConDEPOS(i).x
                        MaxData.MaxCon(MaxData.MaxCon.Length - 1).y = ResultNameAndData.m_DiscConDEPOS(i).y

                    End If
                Next
                For i As Integer = 0 To MaxData.MaxCon.Length - 1 '排序
                    For j As Integer = i + 1 To MaxData.MaxCon.Length - 1
                        If MaxData.MaxCon(j).con > MaxData.MaxCon(i).con Then
                            Dim con As Double = MaxData.MaxCon(j).con
                            Dim DEPOS As Double = MaxData.MaxDEPOS(j).DEPOS
                            Dim DDEP As Double = MaxData.MaxDDEP(j).DDEP
                            Dim WDEP As Double = MaxData.MaxWDEP(j).WDEP

                            Dim x As Double = MaxData.MaxCon(j).x
                            Dim y As Double = MaxData.MaxCon(j).y

                            MaxData.MaxCon(j).con = MaxData.MaxCon(i).con
                            MaxData.MaxDEPOS(j).DEPOS = MaxData.MaxDEPOS(i).DEPOS
                            MaxData.MaxDDEP(j).DDEP = MaxData.MaxDDEP(i).DDEP
                            MaxData.MaxWDEP(j).WDEP = MaxData.MaxWDEP(i).WDEP
                            MaxData.MaxCon(j).x = MaxData.MaxCon(i).x
                            MaxData.MaxCon(j).y = MaxData.MaxCon(i).y

                            MaxData.MaxCon(i).con = con
                            MaxData.MaxDEPOS(i).DEPOS = DEPOS
                            MaxData.MaxDDEP(i).DDEP = DDEP
                            MaxData.MaxWDEP(i).WDEP = WDEP
                            MaxData.MaxCon(i).x = x
                            MaxData.MaxCon(i).y = y

                        End If
                    Next
                Next

            End If
            '---------------------------------------------------------------------------------------
            '浓度结束
            '---------------------------------------------------------------------------------------


            myFrmMain.frmAnalyse.frmRectable.EFlex1.Rows.Count = 1
            '设置列数及行标题
            myFrmMain.frmAnalyse.frmRectable.EFlex1.Cols.Count = 0
            myFrmMain.frmAnalyse.frmRectable.EFlex1.Cols.Count = 11
            myFrmMain.frmAnalyse.frmRectable.EFlex1.AllowSorting = C1.Win.C1FlexGrid.AllowSortingEnum.None
            myFrmMain.frmAnalyse.frmRectable.EFlex1.AllowResizing = C1.Win.C1FlexGrid.AllowResizingEnum.Columns
            myFrmMain.frmAnalyse.frmRectable.EFlex1.AllowDragging = C1.Win.C1FlexGrid.AllowDraggingEnum.None
            myFrmMain.frmAnalyse.frmRectable.EFlex1.AllowMerging = C1.Win.C1FlexGrid.AllowMergingEnum.Free
            For i As Integer = 0 To 2
                myFrmMain.frmAnalyse.frmRectable.EFlex1.Cols(i).AllowMerging = True
            Next
            myFrmMain.frmAnalyse.frmRectable.EFlex1.SetData(0, 0, "序号")
            myFrmMain.frmAnalyse.frmRectable.EFlex1.SetData(0, 1, "污染物名称")
            myFrmMain.frmAnalyse.frmRectable.EFlex1.SetData(0, 2, "排序")
            myFrmMain.frmAnalyse.frmRectable.EFlex1.SetData(0, 3, "坐标[x,y]")
            myFrmMain.frmAnalyse.frmRectable.EFlex1.SetData(0, 4, "平均时间")
            myFrmMain.frmAnalyse.frmRectable.EFlex1.SetData(0, 5, "浓度值[mg/m^3]")
            myFrmMain.frmAnalyse.frmRectable.EFlex1.SetData(0, 6, "出现时刻")
            myFrmMain.frmAnalyse.frmRectable.EFlex1.SetData(0, 7, "背景值[mg/m^3]")
            myFrmMain.frmAnalyse.frmRectable.EFlex1.SetData(0, 8, "预测值[mg/m^3]")
            myFrmMain.frmAnalyse.frmRectable.EFlex1.SetData(0, 9, "标准值")
            myFrmMain.frmAnalyse.frmRectable.EFlex1.SetData(0, 10, "占标率[%]")
            If Me.proj.TempAermod.Control.AllPolluts.AllSelectPollut(0).Dispersion.DEPOS = True Then
                myFrmMain.frmAnalyse.frmRectable.EFlex1.Cols.Count = 14
                myFrmMain.frmAnalyse.frmRectable.EFlex1.SetData(0, 11, "总沉积[g/m^2]")
                myFrmMain.frmAnalyse.frmRectable.EFlex1.SetData(0, 12, "干沉积[g/m^2]")
                myFrmMain.frmAnalyse.frmRectable.EFlex1.SetData(0, 13, "湿沉积[g/m^2]")
            End If



            '获取背景浓度的数组

            myFrmMain.frmAnalyse.frmRectable.EFlex1.AutoSizeCols()
            If jIndexAverageTime >= 0 Then
                '获取数据
                If jIndexAverageTime >= 0 AndAlso nGroup >= 0 Then
                    '设置表格的行数=（关心点个数+1）*输出的最大浓度的个数
                    myFrmMain.frmAnalyse.frmRectable.EFlex1.Rows.Count = Me.proj.TempAermod.OutPutOption.MaxTable.nMax + 1
                    For j As Integer = 0 To Me.proj.TempAermod.OutPutOption.MaxTable.nMax - 1
                        If j >= MaxData.MaxCon.Length Then
                            Exit For
                        End If
                        myFrmMain.frmAnalyse.frmRectable.EFlex1.SetData(j + 1, 0, j + 1)
                        myFrmMain.frmAnalyse.frmRectable.EFlex1.SetData(j + 1, 1, Me.proj.TempAermod.Control.AllPolluts.AllSelectPollut(0).Name)
                        myFrmMain.frmAnalyse.frmRectable.EFlex1.SetData(j + 1, 2, j + 1)
                        myFrmMain.frmAnalyse.frmRectable.EFlex1.SetData(j + 1, 3, MaxData.MaxCon(j).x & "," & MaxData.MaxCon(j).y)
                        myFrmMain.frmAnalyse.frmRectable.EFlex1.SetData(j + 1, 4, cmbAverageTime.Text)
                        myFrmMain.frmAnalyse.frmRectable.EFlex1.SetData(j + 1, 5, FormatNumber(MaxData.MaxCon(j).con / 1000, Me.cmbNumber.SelectedIndex)) '设置污染物浓度。由于软件内部采用的单位为ug/m3，要转在mg/m3,应除以1000
                        If MaxData.MaxCon(j).dateD IsNot Nothing Then
                            myFrmMain.frmAnalyse.frmRectable.EFlex1.SetData(j + 1, 6, MaxData.MaxCon(j).dateD)
                        End If


                        '计算背景浓度。
                        Dim AervarageBack As Double = Me.proj.TempAermod.BackCon.PollutBackCon(0).GetBackCon(Me.cmbAverageTime.Text).AervaggeCon

                        myFrmMain.frmAnalyse.frmRectable.EFlex1.SetData(j + 1, 7, FormatNumber(AervarageBack, Me.cmbNumber.SelectedIndex)) '浓度背景值。取最大值
                        If cmbAddBackCon.Text = "不叠加" Then
                            myFrmMain.frmAnalyse.frmRectable.EFlex1.SetData(j + 1, 8, FormatNumber(MaxData.MaxCon(j).con / 1000, Me.cmbNumber.SelectedIndex)) '浓度背景值。取最大值

                        Else
                            myFrmMain.frmAnalyse.frmRectable.EFlex1.SetData(j + 1, 8, FormatNumber(AervarageBack + MaxData.MaxCon(j).con / 1000, Me.cmbNumber.SelectedIndex)) '浓度背景值。取最大值

                        End If

                        '浓度标准值
                        myFrmMain.frmAnalyse.frmRectable.EFlex1.SetData(j + 1, 9, FormatNumber(Me.proj.TempAermod.Control.AllPolluts.AllSelectPollut(0).ConStandard.GetCon(Me.cmbAverageTime.Text), Me.cmbNumber.SelectedIndex)) '浓度背景值。取最大值

                        If cmbAddBackCon.Text = "不叠加" Then
                            myFrmMain.frmAnalyse.frmRectable.EFlex1.SetData(j + 1, 10, FormatNumber(100 * (MaxData.MaxCon(j).con / 1000) / Me.proj.TempAermod.Control.AllPolluts.AllSelectPollut(0).ConStandard.GetCon(Me.cmbAverageTime.Text), Me.cmbNumber.SelectedIndex)) '占标率
                        Else
                            myFrmMain.frmAnalyse.frmRectable.EFlex1.SetData(j + 1, 10, FormatNumber(100 * (AervarageBack + MaxData.MaxCon(j).con / 1000) / Me.proj.TempAermod.Control.AllPolluts.AllSelectPollut(0).ConStandard.GetCon(Me.cmbAverageTime.Text), Me.cmbNumber.SelectedIndex)) '占标率
                        End If
                        If Me.proj.TempAermod.Control.AllPolluts.AllSelectPollut(0).Dispersion.DEPOS = True Then
                            myFrmMain.frmAnalyse.frmRectable.EFlex1.Cols.Count = 14

                            myFrmMain.frmAnalyse.frmRectable.EFlex1.SetData(j + 1, 11, FormatNumber(MaxData.MaxDEPOS(j).DEPOS, Me.cmbNumber.SelectedIndex)) '设置总沉积。由于软件内部采用的单位为ug/m3，要转在mg/m3,应除以1000
                            myFrmMain.frmAnalyse.frmRectable.EFlex1.SetData(j + 1, 12, FormatNumber(MaxData.MaxDDEP(j).DDEP, Me.cmbNumber.SelectedIndex)) '设置干沉积。由于软件内部采用的单位为ug/m3，要转在mg/m3,应除以1000
                            myFrmMain.frmAnalyse.frmRectable.EFlex1.SetData(j + 1, 13, FormatNumber(MaxData.MaxWDEP(j).WDEP, Me.cmbNumber.SelectedIndex)) '设置湿沉积。由于软件内部采用的单位为ug/m3，要转在mg/m3,应除以1000

                        End If

                    Next
                End If
                For i As Integer = 1 To myFrmMain.frmAnalyse.frmRectable.EFlex1.Rows.Count - 1
                    myFrmMain.frmAnalyse.frmRectable.EFlex1.SetData(i, 0, i)
                Next
            End If
            myFrmMain.frmAnalyse.frmRectable.EFlex1.AutoSizeCols()
            ''GIS绘图-----------------------------------
        Catch ex As Exception
            MessageBox.Show("预测方案可能已经被改变，请重新计算!")
        End Try

    End Sub
#End Region

#Region "显示超标率"
    Private Sub GetOverDataFromPostFileAndShow()
        Dim MyMainFrm As frmMain = My.Application.ApplicationContext.MainForm
        If Me.cmbGroups.SelectedIndex >= 0 And Me.cmbAverageTime.SelectedIndex >= 0 _
                                    And Me.cmbGrid.SelectedIndex >= 0 Then
            Dim FileName As String
            Dim Path As String = System.IO.Path.GetDirectoryName(AermodProject0.SaveName) & "\" & CAermod.GetFileName(AermodProject0.SaveName)
            FileName = Path & "\Aermod\" _
            & Me.proj.ID & "\" & Me.proj.TempAermod.Source.Groups.ArrayGroup(Me.cmbGroups.SelectedIndex).GroupID & "_POST_" _
            & Me.proj.TempAermod.Control.AerageingTime.GetSelectedAerageingTime(Me.cmbAverageTime.SelectedIndex).ToString & ".BIN"

            '获取背景浓度的数组
            Dim disCarePoint3d(-1) As CAermod.Point3D
            Dim disCon(-1) As Double
            For j As Integer = 0 To Me.proj.TempAermod.Receptor.DiscCarts.Length - 1
                If Me.proj.TempAermod.BackCon.PollutBackCon.Item(0).GetBackCon(Me.cmbAverageTime.Text).ListCareBackCon(j).Con >= 0 Then
                    ReDim Preserve disCarePoint3d(disCarePoint3d.Length)
                    ReDim Preserve disCon(disCon.Length)
                    disCarePoint3d(disCarePoint3d.Length - 1) = New CAermod.Point3D
                    disCarePoint3d(disCarePoint3d.Length - 1).x = Me.proj.TempAermod.Receptor.DiscCarts(j).Xcoord
                    disCarePoint3d(disCarePoint3d.Length - 1).y = Me.proj.TempAermod.Receptor.DiscCarts(j).Ycoord
                    disCarePoint3d(disCarePoint3d.Length - 1).z = Me.proj.TempAermod.Receptor.DiscCarts(j).Zelev
                    disCon(disCarePoint3d.Length - 1) = Me.proj.TempAermod.BackCon.PollutBackCon.Item(0).GetBackCon(Me.cmbAverageTime.Text).ListCareBackCon(j).Con
                End If
            Next
            '计算关心点的背景浓度
            Dim ArrayDisBackCon(Me.proj.TempAermod.Receptor.DiscCarts.Length - 1) As Double
            If Me.cmbAddBackCon.Text = "叠加" Then '如果叠加背景值，采用反距离平方法求得每个网格点的背景值
                For i As Integer = 0 To Me.proj.TempAermod.Receptor.DiscCarts.Length - 1
                    '计算背景浓度。如果关心点没有背景值，采用反距离平方法来计算
                    Dim Backcon As Double = Me.proj.TempAermod.BackCon.PollutBackCon.Item(0).GetBackCon(Me.cmbAverageTime.Text).ListCareBackCon(i).Con
                    If Backcon < 0 And disCarePoint3d.Length > 0 Then
                        Dim Grid3d As New CAermod.Point3D
                        Grid3d.x = Me.proj.TempAermod.Receptor.DiscCarts(i).Xcoord
                        Grid3d.y = Me.proj.TempAermod.Receptor.DiscCarts(i).Ycoord
                        Grid3d.z = Me.proj.TempAermod.Receptor.DiscCarts(i).Zelev + Me.proj.TempAermod.Receptor.DiscCarts(i).Zflag
                        Backcon = CAermod.PublicFunction.GetLocationCon(Grid3d, disCarePoint3d, disCon)
                    ElseIf Backcon < 0 Then
                        Backcon = 0
                    End If
                    ArrayDisBackCon(i) = Backcon
                Next
            End If

            '计算网格点的背景浓度值
            Dim GridBackCon(Me.proj.TempAermod.Receptor.SubGridCart.Length - 1)(,) As Double
            For isub As Integer = 0 To Me.proj.TempAermod.Receptor.SubGridCart.Length - 1
                ReDim GridBackCon(isub)(Me.proj.TempAermod.Receptor.SubGridCart(isub).Ynum - 1, Me.proj.TempAermod.Receptor.SubGridCart(isub).Xnum - 1)
            Next
            If Me.cmbAddBackCon.Text = "叠加" And disCarePoint3d.Length > 0 Then '如果叠加背景值，采用反距离平方法求得每个网格点的背景值
                For isub As Integer = 0 To Me.proj.TempAermod.Receptor.SubGridCart.Length - 1
                    Dim Backcon As Double
                    For i As Integer = 0 To Me.proj.TempAermod.Receptor.SubGridCart(isub).Ynum - 1
                        For j As Integer = 0 To Me.proj.TempAermod.Receptor.SubGridCart(isub).Xnum - 1
                            If disCarePoint3d.Length > 0 Then
                                Dim Grid3d As New CAermod.Point3D
                                Grid3d.x = Me.proj.TempAermod.Receptor.SubGridCart(isub).Xinit + Me.proj.TempAermod.Receptor.SubGridCart(isub).Xdelta * j
                                Grid3d.y = Me.proj.TempAermod.Receptor.SubGridCart(isub).Yinit + Me.proj.TempAermod.Receptor.SubGridCart(isub).Ydelta * i
                                Grid3d.z = Me.proj.TempAermod.Receptor.SubGridCart(isub).Elev(i)(j)
                                Backcon = CAermod.PublicFunction.GetLocationCon(Grid3d, disCarePoint3d, disCon)
                            ElseIf Backcon < 0 Then
                                Backcon = 0
                            End If
                            GridBackCon(isub)(i, j) = Backcon
                        Next
                    Next
                Next
            End If

            Dim SaveContourFileName As String = "Over_" & CAermod.GetFileName(FileName) & "_" & Me.proj.TempAermod.Receptor.SubGridCart(Me.cmbGrid.SelectedIndex).Netid
            Dim PostData As New CAermod.PostResult20
            'PostData.GetDataPostBin(Me.proj.TempAermod.Control, Me.proj.TempAermod.Receptor, Me.proj.TempAermod.Control.AllPolluts.AllSelectPollut(0).Dispersion.DEPOS, Me.lstTime.SelectedIndex, FileName, "09292")
            PostData.GetOverDataFromPostBin(Me.proj.TempAermod.Control, Me.proj.TempAermod.Receptor, Me.proj.TempAermod.Control.AllPolluts.AllSelectPollut(0).Dispersion.DEPOS, FileName, "09292", ArrayDisBackCon, Me.proj.TempAermod.Control.AllPolluts.AllSelectPollut(0).ConStandard.GetCon(Me.cmbAverageTime.Text), GridBackCon)
            Dim Grid(Me.proj.TempAermod.Receptor.SubGridCart(Me.cmbGrid.SelectedIndex).Ynum - 1, Me.proj.TempAermod.Receptor.SubGridCart(Me.cmbGrid.SelectedIndex).Xnum - 1) As Double

            Select Case Me.cmbCon.Text
                Case "浓度"
                    If Me.cmbOver.Text = "超标次数[次]" Then
                        SaveContourFileName += "_Cont"
                        For i As Integer = 0 To Me.proj.TempAermod.Receptor.SubGridCart(Me.cmbGrid.SelectedIndex).Ynum - 1
                            For j As Integer = 0 To Me.proj.TempAermod.Receptor.SubGridCart(Me.cmbGrid.SelectedIndex).Xnum - 1
                                Grid(i, j) = PostData.PostSuperscale.SubGridSuperScale(Me.cmbGrid.SelectedIndex)(i, j).SuperCount
                            Next
                        Next
                    ElseIf Me.cmbOver.Text = "超标率[%]" Then
                        SaveContourFileName += "_Rate"

                        For i As Integer = 0 To Me.proj.TempAermod.Receptor.SubGridCart(Me.cmbGrid.SelectedIndex).Ynum - 1
                            For j As Integer = 0 To Me.proj.TempAermod.Receptor.SubGridCart(Me.cmbGrid.SelectedIndex).Xnum - 1
                                Grid(i, j) = PostData.PostSuperscale.SubGridSuperScale(Me.cmbGrid.SelectedIndex)(i, j).SuperRate * 100
                            Next
                        Next

                    ElseIf Me.cmbOver.Text = "最大持续超标时间" Then
                        SaveContourFileName += "_Const"

                        For i As Integer = 0 To Me.proj.TempAermod.Receptor.SubGridCart(Me.cmbGrid.SelectedIndex).Ynum - 1
                            For j As Integer = 0 To Me.proj.TempAermod.Receptor.SubGridCart(Me.cmbGrid.SelectedIndex).Xnum - 1
                                Grid(i, j) = PostData.PostSuperscale.SubGridSuperScale(Me.cmbGrid.SelectedIndex)(i, j).MaxOverTime.nTime
                            Next
                        Next

                    End If


        If Me.cmbAddBackCon.Text = "叠加" Then '如果叠加背景值，采用反距离平方法求得每个网格点的背景值
            SaveContourFileName += "_AddBack"
        End If
                Case "总沉积"
                    'For i As Integer = 0 To Me.proj.TempAermod.Receptor.SubGridCart(Me.cmbGrid.SelectedIndex).Ynum - 1
                    '    For j As Integer = 0 To Me.proj.TempAermod.Receptor.SubGridCart(Me.cmbGrid.SelectedIndex).Xnum - 1
                    '        Grid(i, j) = OnePost.m_SubGridData(Me.cmbGrid.SelectedIndex)(i, j).DEPOS
                    '    Next
                    'Next

                Case "干沉积"
                    'For i As Integer = 0 To Me.proj.TempAermod.Receptor.SubGridCart(Me.cmbGrid.SelectedIndex).Ynum - 1
                    '    For j As Integer = 0 To Me.proj.TempAermod.Receptor.SubGridCart(Me.cmbGrid.SelectedIndex).Xnum - 1
                    '        Grid(i, j) = OnePost.m_SubGridData(Me.cmbGrid.SelectedIndex)(i, j).DDEP
                    '    Next
                    'Next

                Case "湿沉积"
                    'For i As Integer = 0 To Me.proj.TempAermod.Receptor.SubGridCart(Me.cmbGrid.SelectedIndex).Ynum - 1
                    '    For j As Integer = 0 To Me.proj.TempAermod.Receptor.SubGridCart(Me.cmbGrid.SelectedIndex).Xnum - 1
                    '        Grid(i, j) = OnePost.m_SubGridData(Me.cmbGrid.SelectedIndex)(i, j).WDEP
                    '    Next
                    'Next

            End Select
            '用于保存等值线的文件的名称
            ChangeContours(Grid, Me.proj.TempAermod.Receptor.SubGridCart(Me.cmbGrid.SelectedIndex).Xinit, Me.proj.TempAermod.Receptor.SubGridCart(Me.cmbGrid.SelectedIndex).Xdelta, Me.proj.TempAermod.Receptor.SubGridCart(Me.cmbGrid.SelectedIndex).Xnum _
                           , Me.proj.TempAermod.Receptor.SubGridCart(Me.cmbGrid.SelectedIndex).Yinit, Me.proj.TempAermod.Receptor.SubGridCart(Me.cmbGrid.SelectedIndex).Ydelta, Me.proj.TempAermod.Receptor.SubGridCart(Me.cmbGrid.SelectedIndex).Ynum _
                          , AermodProject0.GetOffsetX, AermodProject0.GetOffsetY, SaveContourFileName, True)

            ShowOverToCareTable(PostData)
        End If
    End Sub

    ''' <summary>
    ''' 在表中显示关心点的数据
    ''' </summary>
    ''' <param name="PostData">超标类</param>
    ''' <remarks></remarks>
    Private Sub ShowOverToCareTable(ByVal PostData As CAermod.PostResult20)
        Try
            Dim myFrmMain As frmMain = My.Application.ApplicationContext.MainForm
            myFrmMain.frmAnalyse.frmRectable.EFlex1.Rows.Count = 1
            '设置列数及行标题
            myFrmMain.frmAnalyse.frmRectable.EFlex1.Cols.Count = 8
            myFrmMain.frmAnalyse.frmRectable.EFlex1.AllowSorting = C1.Win.C1FlexGrid.AllowSortingEnum.None
            myFrmMain.frmAnalyse.frmRectable.EFlex1.AllowResizing = C1.Win.C1FlexGrid.AllowResizingEnum.Columns
            myFrmMain.frmAnalyse.frmRectable.EFlex1.AllowDragging = C1.Win.C1FlexGrid.AllowDraggingEnum.None
            myFrmMain.frmAnalyse.frmRectable.EFlex1.AllowMerging = C1.Win.C1FlexGrid.AllowMergingEnum.Free
            For i As Integer = 0 To 2
                myFrmMain.frmAnalyse.frmRectable.EFlex1.Cols(i).AllowMerging = True
            Next
            myFrmMain.frmAnalyse.frmRectable.EFlex1.SetData(0, 0, "序号")
            myFrmMain.frmAnalyse.frmRectable.EFlex1.SetData(0, 1, "污染物名称")
            myFrmMain.frmAnalyse.frmRectable.EFlex1.SetData(0, 2, "关心点")
            myFrmMain.frmAnalyse.frmRectable.EFlex1.SetData(0, 3, "坐标[x,y,z]")
            myFrmMain.frmAnalyse.frmRectable.EFlex1.SetData(0, 4, "平均时间")
            myFrmMain.frmAnalyse.frmRectable.EFlex1.SetData(0, 5, "超标次数")
            myFrmMain.frmAnalyse.frmRectable.EFlex1.SetData(0, 6, "超标率[%]")
            myFrmMain.frmAnalyse.frmRectable.EFlex1.SetData(0, 7, "最大持续超标时间[开始-结束]")
            myFrmMain.frmAnalyse.frmRectable.EFlex1.AutoSizeCols()


            '设置表格的行数=（关心点个数+1）*输出的最大浓度的个数
            myFrmMain.frmAnalyse.frmRectable.EFlex1.Rows.Count = 1
            For i As Integer = 0 To Me.proj.TempAermod.Receptor.DiscCarts.Length - 1
                myFrmMain.frmAnalyse.frmRectable.EFlex1.Rows.Count += 1
                myFrmMain.frmAnalyse.frmRectable.EFlex1.SetData(myFrmMain.frmAnalyse.frmRectable.EFlex1.Rows.Count - 1, 1, Me.proj.TempAermod.Control.AllPolluts.AllSelectPollut(0).Name)
                myFrmMain.frmAnalyse.frmRectable.EFlex1.SetData(myFrmMain.frmAnalyse.frmRectable.EFlex1.Rows.Count - 1, 2, Me.proj.TempAermod.Receptor.DiscCarts(i).Name)
                myFrmMain.frmAnalyse.frmRectable.EFlex1.SetData(myFrmMain.frmAnalyse.frmRectable.EFlex1.Rows.Count - 1, 3, Me.proj.TempAermod.Receptor.DiscCarts(i).Xcoord & "," & Me.proj.TempAermod.Receptor.DiscCarts(i).Ycoord & "," & Me.proj.TempAermod.Receptor.DiscCarts(i).Zelev)
                myFrmMain.frmAnalyse.frmRectable.EFlex1.SetData(myFrmMain.frmAnalyse.frmRectable.EFlex1.Rows.Count - 1, 4, cmbAverageTime.Text)
                myFrmMain.frmAnalyse.frmRectable.EFlex1.SetData(myFrmMain.frmAnalyse.frmRectable.EFlex1.Rows.Count - 1, 5, FormatNumber(PostData.PostSuperscale.CareSuperScale(i).SuperCount, Me.cmbNumber.SelectedIndex)) '设置污染物浓度。由于软件内部采用的单位为ug/m3，要转在mg/m3,应除以1000
                myFrmMain.frmAnalyse.frmRectable.EFlex1.SetData(myFrmMain.frmAnalyse.frmRectable.EFlex1.Rows.Count - 1, 6, PostData.PostSuperscale.CareSuperScale(i).SuperRate * 100)
                myFrmMain.frmAnalyse.frmRectable.EFlex1.SetData(myFrmMain.frmAnalyse.frmRectable.EFlex1.Rows.Count - 1, 7, _
                                                                PostData.PostSuperscale.CareSuperScale(i).MaxOverTime.nTime & "[" & _
                                                                PostData.PostSuperscale.CareSuperScale(i).MaxOverTime.StartTime & _
                                                                "-" & PostData.PostSuperscale.CareSuperScale(i).MaxOverTime.EndTime & "]")

            Next
            myFrmMain.frmAnalyse.frmRectable.EFlex1.AutoSizeCols()
            myFrmMain.frmAnalyse.Refresh()
            ''GIS绘图-----------------------------------
        Catch ex As Exception
            MessageBox.Show("预测方案可能已经被改变，请重新计算!")
        End Try

    End Sub
#End Region


    Private Sub GetDataFromMaxtableFileAndShow()

    End Sub
    Private Sub cmbCon_SelectedIndexChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles cmbCon.SelectedIndexChanged
        GetDataAndShow()
    End Sub
    Private Sub cmbGroups_SelectedIndexChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles cmbGroups.SelectedIndexChanged
        If Me.FileType = AermodSystem.FileType.Post Then
            IntialTime()
        End If

        GetDataAndShow()
    End Sub

    Private Sub cmbAverageTime_SelectedIndexChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles cmbAverageTime.SelectedIndexChanged
        If Me.FileType = AermodSystem.FileType.Post Then
            IntialTime()
        End If
        GetDataAndShow()
    End Sub

    Private Sub cmbRectable_SelectedIndexChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles cmbRectable.SelectedIndexChanged
        GetDataAndShow()
    End Sub
    Private Sub cmbGrid_SelectedIndexChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles cmbGrid.SelectedIndexChanged
        GetDataAndShow()
    End Sub
    Private Sub cmbAddBackCon_SelectedIndexChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles cmbAddBackCon.SelectedIndexChanged
        GetDataAndShow()
    End Sub

    Private Sub cmbOver_SelectedIndexChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles cmbOver.SelectedIndexChanged, cmbNumber.SelectedIndexChanged
        GetDataAndShow()
    End Sub


    Private Sub lstTime_SelectedIndexChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles lstTime.SelectedIndexChanged
        If lstTime.SelectedIndex >= 0 Then
            Me.txtSearchTime.Text = lstTime.SelectedItem.ToString
        End If
        GetDataAndShow()
    End Sub

    Private Sub cmdSearth_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles cmdSearth.Click
        For i As Integer = 0 To lstTime.Items.Count - 1
            If Me.txtSearchTime.Text = lstTime.Items(i).ToString Then
                lstTime.SelectedIndex = i
                Exit Sub
            End If
        Next
        MessageBox.Show("请检查您输入的时刻是否在计算的时间范围之内，或您输入的格式是否正确，尤其注意空格等字符!")
    End Sub

    Private Sub Button1_Click(sender As System.Object, e As System.EventArgs) Handles Button1.Click
        If Me.cmbGroups.SelectedIndex >= 0 And Me.cmbAverageTime.SelectedIndex >= 0 _
                                    And Me.cmbGrid.SelectedIndex >= 0 And Me.lstTime.SelectedIndex >= 0 Then

            Dim FileName As String
            Dim Path As String = System.IO.Path.GetDirectoryName(AermodProject0.SaveName) & "\" & CAermod.GetFileName(AermodProject0.SaveName)
            FileName = Path & "\Aermod\" _
            & Me.proj.ID & "\" & Me.proj.TempAermod.Source.Groups.ArrayGroup(Me.cmbGroups.SelectedIndex).GroupID & "_POST_" _
            & Me.proj.TempAermod.Control.AerageingTime.GetSelectedAerageingTime(Me.cmbAverageTime.SelectedIndex).ToString & ".BIN"
            Dim PostData As New CAermod.PostResult20


            Dim OnePost As CAermod.PostFineBinResult = PostData.GetDataPostBin(Me.proj.TempAermod.Control, Me.proj.TempAermod.Receptor, Me.proj.TempAermod.Control.AllPolluts.AllSelectPollut(0).Dispersion.DEPOS, Me.lstTime.SelectedIndex, FileName, "09292")
            Dim frmAllCare As New frmAllCare
            frmAllCare.TempAermod = Me.proj.TempAermod
            frmAllCare.FileName = FileName
            frmAllCare.ShowDialog()
        End If

    End Sub
End Class